package com.woniuxy.microgoodsserver.auctionmag.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microgoodsserver.auctionmag.mapper.GoodsBrandMapper;
import com.woniuxy.microgoodsserver.auctionmag.mapper.GoodsSortMapper;
import com.woniuxy.microgoodsserver.auctionmag.service.GoodsBrandService;
import com.woniuxy.microgoodsserver.auctionmag.service.GoodsSortService;
import com.woniuxy.microgoodsserver.bean.GoodsBrandBean;
import com.woniuxy.microgoodsserver.bean.GoodsSortBean;
import com.woniuxy.microgoodsserver.bean.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsSortServiceImpl implements GoodsSortService {

    @Resource
    GoodsSortMapper goodsSortMapper;

    @Override
    public PageInfo<GoodsSortBean> sortFindAll(PageRequest pageRequest, GoodsSortBean goodsSortBean) {
         return PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getLimit()).
                doSelectPageInfo(()->goodsSortMapper.sortFindAll(pageRequest,goodsSortBean));

    }

    @Override
    public GoodsSortBean sortFindById(int id) {
        GoodsSortBean goodsSortBean = goodsSortMapper.sortFindAllById(id);
        return goodsSortBean;
    }

    @Override
    public int savaSort(GoodsSortBean goodsSortBean) {
        int a = goodsSortMapper.SaveSort(goodsSortBean);
        return a;
    }

    @Override
    public int updateSort(GoodsSortBean goodsSortBean) {
        int a = goodsSortMapper.updateGoodSortBean(goodsSortBean);
        return a;
    }
}
